using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using FutureOpen.Web.Pages;
using FutureOpen.Core.func.db;
using FutureOpen.Core;
using FutureOpen.Core.func;
using FutureOpen.Core.func.sql;

public partial class test_PresumeUpdate : PageBase
{
    public int uid;
     protected void Page_Load(object sender, EventArgs e)
    {
        base.PageInit();

        if (IsLogin())
        {
            uid = MyUsr;
            if (!Page.IsPostBack)
            {
                LoadInfo();
            }
        }
        else
        {
            GoBack();
        }
    }

    private void LoadInfo()
    {
        DataRow dr = ResumeProvider.GetPResume(this.uid);
        DataRow druser = UsrProvider.GetUsrById(this.uid);

        if (druser != null)
        {
            this.lblName.Text = druser["usr_name"].ToString() + "(" + druser["usr_email"].ToString() + ")";
        }

        if (dr != null)
        {
            this.tbBio.Text = dr["presume_bio"].ToString();
            this.tbTech.Text = dr["presume_tech"].ToString();
            this.tbHon.Text = dr["presume_honor"].ToString();
            this.tbEdu.Text = dr["presume_study"].ToString();
            this.tbExp.Text = dr["presume_exp"].ToString();

            if (Convert.ToInt16(dr["presume_status"]) == ResumeProvider.RESUME_CLOSE)
            {
                this.RadioButton3.Checked = true;
            }
            else if (Convert.ToInt16(dr["presume_status"]) == ResumeProvider.RESUME_FRD)
            {
                this.RadioButton2.Checked = true;
            }
            else
            {
                this.RadioButton1.Checked = true;
            }
        }
        else
        {
            this.RadioButton1.Checked = true; 
        }

      
    }

    protected void lbUpdate_Click(object sender, EventArgs e)
    {
        UpdatePresume();
    }

    private void UpdatePresume()
    {
        int status = ResumeProvider.RESUME_OPEN;
        if(RadioButton2.Checked)
        {
            status = ResumeProvider.RESUME_FRD;
        }
        else if (RadioButton3.Checked)
        { 
            status = ResumeProvider.RESUME_CLOSE;

        }
        string bio = this.tbBio.Text.Trim();
        string exp = this.tbExp.Text.Trim();
        string honor = this.tbHon.Text.Trim();
        string study = this.tbEdu.Text.Trim();
        string tech = this.tbTech.Text.Trim();

        ResumeProvider.UpdatePresume(uid, bio, tech, honor, exp, study, status);
        Response.Redirect("PResumeView.aspx?usrid=" + uid);
       
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("PResumeView.aspx?usrid=" + uid);
    }
}
